programming4us
           
 
 
Windows

SOA with .NET and Windows Azure : Service Hosting with WCF (part 2) - Self-Hosted Services

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
12/15/2010 11:28:30 AM

Self-Hosted Services

A self-hosted service can be any managed application or application domain. Managed applications include Windows Forms applications, console applications, or Windows services. Similar to other hosting environments, the ServiceHost<T> generic class is used to host WCF endpoints within any .NET application. If the host is a Windows Forms or console application, it must be running to provide an application domain to host the communication endpoints.

Self-hosted services offer unique advantages, such as using TCP, IPC, or MSMQ for transport, utilizing HTTP with multiple ports (besides port 80), and programmatic access to hosting features. With self-hosting, the service is not limited to HTTP-based addresses as is the case with IIS.

SOA Principles & Patterns

A primary service-orientation principle that can greatly impact service hosting considerations is Service Autonomy . It advocates that services have as much control over their underlying execution environment as possible in order to guarantee a high level of behavioral predictability. This generally implies that allocated resources are desirable, whereas shared resources are not.


It is a flexible approach, but it has the least amount of server features. It is not a valid option if you need high availability, reliability, and a management view. The most common scenario for self-hosting is a smart client application which, when you fire it up, provides a connection point for other applications. Peer-to-peer applications are a common example of self-hosted services.

The following example shows a service that, when implemented in a Windows Forms application or a Console application, would be classified as self-hosted. In this case the ServiceHost class is instantiated by providing the constructor the interface and base addresses (and the binding is inferred from the address which is in the configuration file shown in Example 2).

Example 2.
Uri[] baseAddresses = new Uri[]
{
new Uri(ConfigurationManager.AppSettings["tcpBaseAddress"]),
new Uri(ConfigurationManager.AppSettings["httpBaseAddress"])
};
ServiceHost serviceHost =
new ServiceHost(typeof(AccountService), baseAddresses);
serviceHost.Open();

The base address collection provided to the ServiceHost instance is dynamically configured by reading the settings from the Web.Config file:

Example 3.
<appSettings>
<add key="tcpBaseAddress"
value="net.tcp://localhost:1234"/>
<add key="httpBaseAddress"
value="http://localhost:8000"/>
</appSettings>

The ServiceHost class uses endpoint information, such as the address, binding, and contract, to initialize and create a process and its underlying communication stack in the application domain that receives messages:

Example 4.
<services>
<service name ="AccountService">
<endpoint name="EndPoint1"
address=""
binding="netTcpBinding"
contract="IAccount"/>
<endpoint name="EndPoint2"
address=""
binding="basicHttpBinding"
contract="IAccount"/>
</service>
</services>

.NET 4.0 simplifies WCF configuration by providing a default configuration and behavior. The default configuration also includes a default endpoint. Therefore, it is possible to consume a WCF service with no supporting configuration file. The binding defaults to basic HTTP (BasicHttpBinding), but if a different binding is required, it needs to be changed in the App.Config file. This allows you to rapidly create a Web service similar to .ASMX development.

Note that this technique is not generally recommended when applying service-orientation as it tends to promote RPC-style inter-service relationships.

Other -----------------
- SOA with .NET and Windows Azure : Service Implementation with WCF (part 2)
- SOA with .NET and Windows Azure : Service Implementation with WCF (part 1)
- Windows 7 : Thwarting Spam with Windows Live Mail’s Junk Filter (part 2) - Blocking Countries and Languages
- Windows 7 : Thwarting Spam with Windows Live Mail’s Junk Filter (part 1)
- Windows 7 : Configuring Windows Defender to Scan Email
- Windows 7 : Protecting Yourself Against Email Viruses
- Windows 7 : Understand Internet Explorer’s Advanced Security Options
- SOA with .NET and Windows Azure : WCF Services - Overview
- SOA with .NET and Windows Azure : Web Services (ASMX and WSE)
- Windows 7 : Enhancing Your Browsing Security (part 6) - Managing Add-Ons
- Windows 7 : Enhancing Your Browsing Security (part 5) - Encoding Addresses to Prevent IDN Spoofing
- Windows 7 : Enhancing Your Browsing Security (part 4) - Thwarting Phishers with the SmartScreen Filter
- Windows 7 : Enhancing Your Browsing Security (part 3) - Changing a Zone’s Security Level
- Windows 7 : Enhancing Your Browsing Security (part 2) - Adding and Removing Zone Sites
- Windows 7 : Enhancing Your Browsing Security (part 1) - Blocking Pop-Up Windows
- Windows 7 : Configuring Internet Explorer Security - Enhancing Your Browsing Privacy (part 4) - InPrivate Browsing and Filtering
- Windows 7 : Configuring Internet Explorer Security - Enhancing Your Browsing Privacy (part 3) - Enhancing Online Privacy by Managing Cookies
- Windows 7 : Configuring Internet Explorer Security - Enhancing Your Browsing Privacy (part 2) - Clearing the Address Bar List
- Windows 7 : Configuring Internet Explorer Security - Enhancing Your Browsing Privacy (part 1)
- Windows 7 : Managing Windows Firewall (part 2)
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us